package com.yss.kettle.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Date;
import javax.servlet.http.HttpServletResponse;

import com.yss.common.core.utils.uuid.IdUtils;
import com.yss.common.security.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yss.common.logger.annotation.Log;
import com.yss.common.logger.enums.BusinessType;
import com.yss.common.security.annotation.RequiresPermissions;
import com.yss.kettle.domain.JobDutiesTask;
import com.yss.kettle.service.IJobDutiesTaskService;
import com.yss.common.core.web.controller.BaseController;
import com.yss.common.core.web.domain.AjaxResult;
import com.yss.common.core.web.page.TableDataInfo;

/**
 * 采集任务和作业任务关联关系Controller
 *
 * @author yss
 * @date 2023-04-25
 */
@RestController
@RequestMapping("/dutiesTask" )
public class JobDutiesTaskController extends BaseController {
    @Autowired
    private IJobDutiesTaskService jobDutiesTaskService;

/**
 * 查询采集任务和作业任务关联关系列表
 */
@RequiresPermissions("kettle:task:list" )
@GetMapping("/list" )
    public TableDataInfo list(JobDutiesTask jobDutiesTask) {
        startPage();
        List<JobDutiesTask> list = jobDutiesTaskService.selectJobDutiesTaskList(jobDutiesTask);
        return getDataTable(list);
    }


    /**
     * 获取采集任务和作业任务关联关系详细信息
     */
    @RequiresPermissions("kettle:task:query" )
    @GetMapping(value = "/{id}" )
    public AjaxResult getInfo(@PathVariable("id" ) String id) {
        return success(jobDutiesTaskService.getById(id));
    }

    /**
     * 新增采集任务和作业任务关联关系
     */
    @RequiresPermissions("kettle:task:add" )
    @Log(title = "采集任务和作业任务关联关系" , businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody @Validated JobDutiesTask jobDutiesTask) {
        jobDutiesTask.setId(IdUtils.fastSimpleUUID());

        return toAjax(jobDutiesTaskService.save(jobDutiesTask));
    }

    /**
     * 修改采集任务和作业任务关联关系
     */
    @RequiresPermissions("kettle:task:edit" )
    @Log(title = "采集任务和作业任务关联关系" , businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody @Validated JobDutiesTask jobDutiesTask) {
        return toAjax(jobDutiesTaskService.updateById(jobDutiesTask));
    }

    /**
     * 删除采集任务和作业任务关联关系
     */
    @RequiresPermissions("kettle:task:remove" )
    @Log(title = "采集任务和作业任务关联关系" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}" )
    public AjaxResult remove(@PathVariable List<String> ids) {
        return toAjax(jobDutiesTaskService.removeByIds(ids));
    }
}
